﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OSGeo.MapGuide;
using System.Configuration;
namespace IGIS
{
    public partial class _Default : utilityfunctions
    {
       public  String webLayout =ConfigurationManager.AppSettings["webLayout"];
       public String defaultUser = ConfigurationManager.AppSettings["defaultUser"];
       public String defaultPassword = ConfigurationManager.AppSettings["defaultPassword"];
       public String sessionId = "";
        protected void Page_Load(object sender, EventArgs e)
        {  


    try
    {

        if (null != Session["logedin"])
        {
            if (Session["logedin"].ToString() == "true")
            {
                // Initialize a session and register a variable to hold the
                // session id, then initialize the Web Extensions, connect
                // to the site, and create a session.

                InitializeWebTier();
                //MapGuideApi.MgInitializeWebTier(@"C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2012\www\webconfig.ini");
                //  MgUserInformation userInfo = new MgUserInformation("Anonymous", "");
                // MgSite site = new MgSite();
                //site.Open(userInfo);
                //  String sessionId = site.CreateSession();
                //String webLayout = "Library://rany1/Layout/gis.WebLayout";
                /* public String defaultUser = ConfigurationManager.AppSettings["defaultUser"];
               public String defaultPassword = ConfigurationManager.AppSettings["defaultPassword"];*/
                MgUserInformation userInfo = new MgUserInformation(defaultUser, defaultPassword);
                MgSite site = new MgSite();
                site.Open(userInfo);
                sessionId = site.CreateSession();
            }
            else { RedirectPage(); }
        }
        else
        {
            RedirectPage();
        }
    }
    catch (Exception ex)
    {
        Response.Write(ex.Message);
    }

        }

        protected void RedirectPage()
        {

            Response.Redirect("~/login.aspx");
        }
    }
}